package paintObjects;

import interfaces.IPaintable;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.io.Serializable;

public class Line implements IPaintable, Serializable {

	private int xPostion;
	private int yPosition;
	private int xEnd;
	private int yEnd;
	private Color color;

	public Line(int xPostion, int yPosition, Color color) {

		this.xPostion = xPostion;
		this.yPosition = yPosition;
		this.xEnd = xPostion;
		this.yEnd = yPosition;
		this.color = color;
	}

	@Override
	public void painting(Graphics2D g, boolean tmp) {

		if (tmp) {

			float[] dash = { 5f, 5f };

			g.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT,
					BasicStroke.JOIN_BEVEL, 1f, dash, 0));

		} else {

			g.setStroke(new BasicStroke(2f));

		}

		g.setPaint(color);
		g.drawLine(xPostion, yPosition, xEnd, yEnd);

	}

	@Override
	public void update(int x, int y) {
		this.xEnd = x;
		this.yEnd = y;
	}

}
